/**
 *Copyright (c) 2024 watereyes
 * safetymanagement is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */
package com.koron.improvement.controller;

import com.koron.common.StaffAttribute;
import com.koron.common.bean.StaffBean;
import com.koron.common.permission.SPIAccountAnno;
import com.koron.improvement.bean.AssessmentElement;
import com.koron.improvement.service.api.AssessmentStatisticService;
import com.koron.improvement.utils.BusinessCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.swan.bean.MessageBean;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

@Api(tags = "AssessmentStatistic", description = "持续改进统计分析")
@RestController
@RequestMapping("/assessment/statistic")
public class AssessmentStatisticController {

    @Autowired
    private AssessmentStatisticService assessmentStatisticService;

    @ApiOperation("考核要素添加")
    @RequestMapping(value = "/saveAssessmentElement.htm", method = {RequestMethod.POST})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "assessmentElement", value = "考察要素实体类"),
    })
    public MessageBean<?> saveAssessmentElement(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user, @RequestBody List<AssessmentElement> assessmentElementList) {
        if (null==user){
            MessageBean<?> msg=new MessageBean<>();
            msg.setCode(BusinessCode.NOT_LONGIN.getCode());
            msg.setDescription(BusinessCode.NOT_LONGIN.getDescription());
            return msg;
        }
        return assessmentStatisticService.saveAssessmentElement(user, assessmentElementList);
    }

    @ApiOperation("考核要素获取列表")
    @RequestMapping(value = "/getAssessmentElementList.htm", method = {RequestMethod.GET})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "assessmentType", value = "考核要素类型:0企业绩效,1个人绩效,2 PBC排名,3标准化评价", dataType = "Integer"),

    })
    public MessageBean<?> getAssessmentElementList(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user, Integer assessmentType) {
        if (null==user){
            MessageBean<?> msg=new MessageBean<>();
            msg.setCode(BusinessCode.NOT_LONGIN.getCode());
            msg.setDescription(BusinessCode.NOT_LONGIN.getDescription());
            return msg;
        }
        return assessmentStatisticService.getAssessmentElementList(user, assessmentType);
    }


    @ApiOperation("日常考核统计")
    @RequestMapping(value = "/dailyAssessment.htm", method = {RequestMethod.GET})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "assessmentType", value = "考核类型", dataType = "Integer"),

    })
    public MessageBean<?> dailyAssessment(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user, Integer assessmentType) {
        if (null==user){
            MessageBean<?> msg=new MessageBean<>();
            msg.setCode(BusinessCode.NOT_LONGIN.getCode());
            msg.setDescription(BusinessCode.NOT_LONGIN.getDescription());
            return msg;
        }
        return assessmentStatisticService.getAssessmentElementList(user, assessmentType);
    }
}
